package string;

import java.util.Arrays;

/**
 * String 支持正则表达式的split方法
 * String[] split(String regex)
 */
public class SplitDemo {
    public static void main(String[] args) {
        // 字符串的分割
        String str="a1a11a111,1b1111bb,ccc";
        String[] strs=str.split(",");
        //按照数字分割
        strs=str.split("[0-9]+");
        for (int i=0;i<strs.length;i++){
            System.out.println(strs[i]);
        }
        //System.out.println();
        System.out.println(Arrays.toString(strs));
        //
        System.out.println("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
        String line="123.172.88.24";
        String[] ip=line.split("\\.");
        System.out.println(Arrays.toString(ip));
        System.out.println("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
        line="=123=1=3==5=======";
        ip=line.split("=");//后面的=分割出的
        System.out.println(Arrays.toString(ip));
        System.out.println(ip.length);//6
        System.out.println("--------------------------------");
        for (int i=0;i<ip.length;i++){
            System.out.println(ip[i]);
        }
    }
}
